<template>
    <div class="template-index-Lu">
        <commpVxeTable
            :isCanWrap="true"
            :occupancyHeight="occupancyHeight"
            :key="reCommpVxeTable"
            :config="dataTableConfig"
            :columns="columnsVxe"
            :formItem="formItem"
            @checkboxChange="checkboxChange"
            ref="administrativeOffice"
            @searchEvent="searchEvent"
            @resetEvent="resetEvent"
            >
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline">
                    <a-form-item>
                        <a-button class="blue-btn" @click="reviseClick(row)" icon="edit">办理</a-button>
                    </a-form-item>
                </a-form>
            </template>
            <template v-slot:operation_fsqr="{row}" data-desc="申请人">
                <span style="padding-right: 21;" v-if="row.fsqr.length == 2">
                    <span v-for="(trem,tI) in row.fsqr.split('')" :key="tI" >
                        {{trem}}
                        <span v-if="tI+1 !== row.fsqr.split('').length">&nbsp;&nbsp;</span>
                    </span>
                </span>
                <span style="padding-right: 21;" v-else>{{ row.fsqr }}</span>
            </template>
        </commpVxeTable>
        <handleModal ref="handleModalRef" @resetEvent="resetEvent"></handleModal>
    </div>
</template>
<script>
import  commpVxeTable   from '@/components/commp-vxe-table/commp-vxe-table.vue'
import handleModal from '../modal/handleModal.vue'
import {queryByJodId} from './service/index'
import YchConstant from "@/api/YchConstant";
export default {
    components: {
        commpVxeTable,
        handleModal
    },
    props: {
        occupancyHeight: {
            type:Number,
            default: 0,
            requrie: false,
        }
    },
    data() {
        return {
            reCommpVxeTable: '',
            url: {
                list:YchConstant.SPZX_OA + '/newflow-lgqs/flowJobPage',// 离岗请示-分页查询列表
                list_url: YchConstant.PREFIX_EFORM + '/manage/actAppHelp/list',
                delete_url: YchConstant.PREFIX_EFORM + '/manage/actAppHelp/delete',
                sync_url: YchConstant.PREFIX_EFORM + '/manage/actAppHelp/sync',
                uploadHelps_url: YchConstant.PREFIX_EFORM + '/manage/actAppHelp/upload',
            },
            dataTableConfig: {
                api: YchConstant.SPZX_OA + '/mydbyb/DbList',
                rowId: 'id',
                urlType: true,
                paramet: {}
            },
            columnsVxe: [
                {
                    title: '标题',
                    field: 'fbt',
                    // width: 100,
                    titleInterval:true,
                    slots: {
                        header:'data1_header',
                    }
                },{
                    title: '摘要',
                    field: 'fzy',
                    align:'left',
                    titleInterval:true,
                    slots: {
                        header:'data2_header',
                    }
                },{
                    title: '发起人',
                    field: 'fsqr',
                    width: 80,
                    interval:true,
                    slots: {
                        default:'operation_fsqr',
                    }
                },{
                    title: '发送时间',
                    field: 'fsqsj',
                    width: 150,
                },{
                    title: '环节名称',
                    field: 'fhjmc',
                },{
                    title: '操作',
                    field: 'jobid',
                    width: 100,
                    titleInterval:true,
                    slots: {
                    // 使用插槽模板渲染
                        header:'data3_header',
                        default: 'operation_btn',
                    },
                }
            ],
            formItem: [
                {
                    label: '申请人',
                    model: 'fsqr',
                },
                {
                    label: '流程名称',
                    model: 'flcmb',
                    type:'Select',
                    options:[{
                        label:'离岗请示',
                        value:'OA_LGQS'
                    },{
                        label:'请休假',
                        value:'OA_QXJ'
                    },{
                        label:'加班值班',
                        value:'OA_JBZB'
                    },{
                        label:'出差审批',
                        value:'NK_CCSP'
                    },{
                        label:'行政事务审批',
                        value:'OA_XZSWSP'
                    },{
                        label:'宣传信息审批',
                        value:'OA_XCXXSP'
                    },{
                        label:'会议室申请管理',
                        value:'OA_HYSSQGL'
                    },{
                        label:'办公用品申请',
                        value:'OA_BGYPSQ'
                    }]
                },
            ],
            idList: [],
            formData: {},
        }
    },
    methods: {
        // 勾选
        checkboxChange(val){
            //console.log('已选择',val)
            this.idList = []
            if(val.length){
                val.forEach(item => {
                    this.idList.push(item.id)
                });
            }
        },
        // 搜索
        searchEvent(){
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
        },
        // 重置
        resetEvent(){
            //console.log('重置')
            this.reCommpVxeTable = Date.now()
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
            }
        },
        // 点击办理
        reviseClick(row){
            //console.log(row)
            let data = {
                jobId: row.jobid,
                lcmbbm: row.flcmb,
                fpid: row.fpid,
            }
            queryByJodId(data).then(res => {
                //console.log(res)
                if(res.code == 200){
                    this.$nextTick(_ => {
              //console.log('-------------',res,'++++++++++++++')

                        this.$refs.handleModalRef.modalClick(res.result)
                    })
                }
            })
        },
    },
}
</script>
